from bazhuayun.cangkuguanli.base_api import BaseApi
from bazhuayun.utils.utils import Utils


class WarehousePage(BaseApi):

    def create_warehouse(self,data):
        create_warehouse_url = "http://api.wxorder.taover.com/v1/wxorderware"
        req = {
            "method": "POST",
            "url": create_warehouse_url,
            "json": data,
            "headers": {"Authorization": self.get_token()}
        }
        r = self.send_api(req)
        return r

    def search_warehouse(self, data):
        search_url = f"http://api.wxorder.taover.com/v1/wxorderware"
        req = {
            "method": "get",
            "url": search_url,
            "headers": {"Authorization": self.get_token()},
            "params": data
        }
        res = self.send_api(req)
        return res

    def delete_warehouse(self):
        delete_url = f"http://api.wxorder.taover.com/v1/wxorderware/{Utils.get_yaml_data('../config/repository.yaml')}"
        req = {
            "method": "delete",
            "url": delete_url,
            "headers": {"Authorization": self.get_token()}
        }
        res = self.send_api(req)
        return res
